import java.io.*;
import java.util.*;


/******************************************************************
 * public class TickSidFileLoader
 * public void setFileName (File file)
 * public Hashtable getTickHashTable ()
 * private void loadTickSidFile ()
 *
 ******************************************************************/

public class TickSidFileLoader  {

    private Hashtable tickHashTable = null;
    private String file_name = null;
    private File name = null;
    private String dataDir = "C:/java/projects/stocks/MyStock/Data";

    public void setFileName( String  fileName )
    {
	file_name = fileName;
    }

    public void loadTickSidFile () {

	name = new File (file_name);

        if ( !name.exists() ) {
	    System.out.println("File:"+name.getName()+" not found!");
	    return;
	}

	if ( name.isFile() ) {
	    try {
               RandomAccessFile r =  new RandomAccessFile( name, "r" );
               String text;
	       String temp[] = {"",""};
	       CleanDupString tickTable = new CleanDupString();

               while( ( text = r.readLine() ) != null ) {

		   StringTokenizer tokens = new StringTokenizer(text);
		   int m = 0;

		   while (tokens.hasMoreTokens() && m<2) {
		       temp[m]= tokens.nextToken();
		       m++;
		   }

		   tickTable.putStringInToTable(temp[0], temp[1]);
	       }
	       //tickTable.printHashTable(tickTable.getStringHashTable());
	       tickHashTable = tickTable.getStringHashTable();
	   }
	   catch( IOException e ) {

	   }
       }
    }

    public Hashtable getTickHashTable () {
	return tickHashTable;
    }
}



